package com.cangsan.erhai.util;

import com.cangsan.erhai.entity.SysUser;
import com.cangsan.erhai.security.WechatAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtil {

    public static SysUser getUser(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        WechatAuthenticationToken wechatAuthenticationToken =(WechatAuthenticationToken) authentication;
        SysUser user= (SysUser) wechatAuthenticationToken.getPrincipal();
        return user;
    }
}
